"""
浏览器回退、前进、设置窗口大小
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
#创建一个浏览器实例
driver = webdriver.Edge()
driver.get("http://www.baidu.com")
sleep(1)
driver.get("http://www.qq.com")
sleep(1)
driver.get("http://www.tmall.com")
sleep(1)
#回退一层网页
driver.back()
sleep(1)
#回退一层网页
driver.back()
sleep(2)
#前进一层网页
driver.forward()
sleep(10)
#回退一层网页
driver.back()
sleep(10)
# #设置窗口大小
# driver.set_window_size(1200,600)
# sleep(2)
# driver.minimize_window()
# sleep(5)
# driver.maximize_window()
# sleep(2)
# driver.close()  #关闭当前按窗口
# handle1 = driver.window_handles
# #切换到百度新闻的窗口，定位上面的某个元素后关闭窗口
# for h in handle1:
#     driver.switch_to.window(h)
#     if "新闻" in driver.title:
#        break
# sleep(2)
# #查找文本为"热点要闻"的代码
# a = driver.find_element(By.LINK_TEXT,"热点要闻")
# print(a.get_dom_attribute("href"))
# sleep(2)
# driver.close()

